﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ADNDNeteworking.Netowork.MessageContainer
{
    public class DNDMessage : IComparable
    {
        private string currentUserName;
        private string messageValue;
        private string fromUserName;
        private byte[] data;
        private DateTime timeStamp;

        private const int MAX_DATA_SIZE = 1024;

        #region Properties
        public string MessageValue
        {
            get { return messageValue; }
            set { messageValue = value; }
        }
        public DateTime TimeStamp
        {
            get { return timeStamp; }
            set { timeStamp = value; }
        }
        public string FromUserName
        {
            get { return fromUserName; }
            set { fromUserName = value; }
        }
        public byte[] Data
        {
            get { return data; }
            set { data = value; }
        }
        public string CurrentUserName
        {
            get { return currentUserName; }
            set { currentUserName = value; }
        }
        #endregion

        public DNDMessage(string currentUserName, string message, string fromUserName, byte[] data, DateTime date )
        {
            CurrentUserName = currentUserName;
            MessageValue = message;
            FromUserName = fromUserName;
            Data = data;
            timeStamp = date;
        }

        public DNDMessage()
        {
            CurrentUserName = string.Empty;
            MessageValue = string.Empty;
            FromUserName = string.Empty;
            Data = new byte[MAX_DATA_SIZE];
            TimeStamp = DateTime.Now;
        }

        #region IComparable Members
        //Added just in case i needed some sort. 
        //The interface and this function can be removed.
        public int CompareTo(object message)
        {
            DNDMessage m = (DNDMessage)message;

            if (m == null)
                return 0;

            if (m.timeStamp > TimeStamp)
                return 1;
            else if (m.TimeStamp < TimeStamp)
                return -1;
            else
                return 0;
        }

        #endregion
    }
}
